<!DOCTYPE HTML>
<html>
<head>
    <title>Error</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body>
<div id="form1" style="padding-left: 60px">
    <span style="width:80px;display:inline-block;">内容：</span>
    <input id="content" class="mini-textarea" style="width:155px;" value="<%= result.attributes.content%>"/>
    <br/><br/>
    <span style="width:80px;display:inline-block;">名称：</span>
    <input id="name" class="mini-textbox" style="width:155px;" value="<%= result.attributes.name%>"/>
    <br/><br/>
    <div style="margin: 0 auto;text-align: center">
        <a class="mini-button " iconCls="icon-ok" onclick="templateEdit()">确定</a>
        <a class="mini-button" iconCls="icon-cancel" onclick="onCancel">取消</a>
    </div>
</div>
</body>
<script>

    let objectId = '<%=result.id%>';
    function  templateEdit() {
        let form = new mini.Form("#form1");
        form.validate();
        if (form.isValid() == false) {
            alert("请正确填写数据")
            return
        };
        let content = mini.get("content").getValue();
        let name = mini.get("name").getValue();
        $.ajax({
            url:"/getdata/templateForThreadEdit",
            type:"post",
            data:{
                objectId,
                content,
                name
            },
            success:function (result) {
                if(result =="1"){
                alert("更新成功")
                    CloseWindow("edit");
                }else{
                    alert("更新失败")
                    CloseWindow("edit");
                }
            }
        })
    }

    function CloseWindow(action) {
        if (action == "close" && form.isChanged()) {
            if (confirm("数据被修改了，是否先保存？")) {
                return false;
            }
        }
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }

    function onCancel(e) {
        CloseWindow("cancel");
    }
</script>
</html>